package com.chris.core.socket.netty.run;

import com.chris.core.socket.netty.dto.SocketTypeEnum;
import com.chris.core.socket.netty.handler.ObjectServerHandler;
import com.chris.core.socket.netty.util.NettyRunTimeUtil;
import com.chris.core.socket.netty.util.NettyServerUtil;
import io.netty.channel.ChannelPipeline;

import java.io.File;

/**
 * Object socket 通讯类
 * 主要用于 服务端/客户端 都是 Java
 */
@Deprecated
public class NettyOjectServer {



    public static void main(String[] args) throws InterruptedException {
        NettyRunTimeUtil.runTimeBreakMark="\r\n";

        NettyServerUtil service = new NettyServerUtil(10105,180,NettyRunTimeUtil.runTimeBreakMark, SocketTypeEnum.ObjectSocket) {
            @Override
            public void AddChannelHandler(ChannelPipeline pipeline) {

                //自定义事件
                pipeline.addLast(new ObjectServerHandler());

            }
        };

        service.Open();
/*
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(16000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (NettyRunTimeUtil.getOnlineCount()>0) {

                    File file = new File("./a.tar");
                    service.sendFileMsg(file, NettyRunTimeUtil.SocketChannelMap.entrySet().stream().findFirst().get().getValue().getId());
                }
            }

        });
        t.start();

        while (true)
        {

        }*/
    }


}
